#pragma once
#ifndef VECTOR_2D_H
#define VECTOR_2D_H

#include"Position.h"
#include<cmath>

class Vector_2D
{
private:
    Position val;
    double x;
    double y;
    double len;
    friend class Body;
public:
    Vector_2D();
    Vector_2D(int xcoor,int ycoor);
    Vector_2D(const Position& start, const Position& end);
    Vector_2D(const Position& obj);

    friend Vector_2D operator+(const Vector_2D obj1, const Vector_2D obj2);
    friend Vector_2D operator-(const Vector_2D obj1, const Vector_2D obj2);
    Vector_2D operator+=(const Vector_2D obj);
    Vector_2D operator-=(const Vector_2D obj);
    Vector_2D operator*(const double& num) const;
    Vector_2D operator/(const double& num) const;
    Vector_2D operator=(const Vector_2D& obj);
    
    friend std::ostream& operator<<(std::ostream& output, Vector_2D obj);//重载运算符

    void set_zeroVec();
    void setVec(double x,double y);
    void cal_len();//计算长度

    double get_len();//获得长度
};

#endif // VECTOR_2D_H


